package com;

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.chrome.ChromeDriver;

import java.io.File;
import java.io.IOException;

/**
 * @program: testcode01
 * @author: JCM
 * @create: 2023-10-17 21:53
 * @description:
 **/
public class ShotTest extends AutoTest{
    public static void main(String[] args) throws IOException {
        ChromeDriver driver = createDriver();
        driver.get("https://www.baidu.com");
        driver.findElement(By.cssSelector("#kw")).sendKeys("Java");
        driver.findElement(By.cssSelector("#su")).click();
        // 屏幕截图（截图是png 格式，所以下面 OutputType 我们使用 FILE
        File srcFile = driver.getScreenshotAs(OutputType.FILE);
        // 把屏幕截图放在指定路径下
        String filename = "my.png";
        FileUtils.copyFile(srcFile,new File(filename));
    }
}
